package com.example.ali.service.impl;

import com.example.ali.domain.dto.MyDetectionDto;
import com.example.ali.service.IAliOcrService;
import com.example.ali.service.IMyBuildDtoService;
import com.example.ali.service.IMyDeteionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.io.InputStream;
import java.util.List;
import java.util.Map;

/**
 * 〈〉
 *
 * @author hero
 * @create 2024/5/29
 * @since 1.0.0
 */
@Service
public class MyDeteionServiceImpl implements IMyDeteionService {

    @Autowired
    IAliOcrService aliOcrService;
    @Autowired
    @Qualifier("MyDetectionBuildDtoService")
    IMyBuildDtoService<MyDetectionDto> myBuildDtoService;


    @Override
    public List<MyDetectionDto> getOcrRes(InputStream fileInputStream) {
        //获取OCR识别结果
        List<Map<String, String>> mapList = aliOcrService.getValueMap(fileInputStream, 3);
        //构建DTO封装成DTO
        List<MyDetectionDto> detectionDtoList = myBuildDtoService.buildDto(mapList);
        return detectionDtoList;
    }
}